package com.css.zfzx.sjcj.modules.yhdisaster.controller;

import com.alibaba.fastjson.JSONObject;
import com.css.bpm.platform.base.response.RestResponse;
import com.css.zfzx.sjcj.modules.yhdisaster.service.YhAnalysisQueryService;
import com.css.zfzx.sjcj.modules.yhdisaster.viewobjects.AnalysisQueryVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RequestMapping("/yh/yhAnalysisQuery")
@RestController
public class YhAnalysisQueryController {

    @Autowired
    YhAnalysisQueryService yhAnalysisQueryService;
    /**
     *饼状分析
     * @param analysisQueryVo
     * @return
     */
    @GetMapping("/analysisYhEarthFortification")
    public RestResponse analysisQuery(AnalysisQueryVo analysisQueryVo){
        RestResponse responseRest = null;
        JSONObject jsonObject = new JSONObject();
        try {
            //抗震设防类别
            List<Map> mapList = yhAnalysisQueryService.queryCountYhEarthFortification(analysisQueryVo);
            //原抗震设防烈度
            List<Map> yhEarthIntensity = yhAnalysisQueryService.queryCountYhEarthIntensity(analysisQueryVo);
            //现抗震设防烈度
            List<Map> countYhNowEarthQh = yhAnalysisQueryService.queryCountYhNowEarthQh(analysisQueryVo);
            //场地类型
            List<Map> countYhFieldType = yhAnalysisQueryService.queryCountYhFieldType(analysisQueryVo);
            //地段类型
            List<Map> countYhLotType =yhAnalysisQueryService.queryCountYhLotType(analysisQueryVo);
            //现存病害
            List<Map> yhExistingVirus = yhAnalysisQueryService.queryCountYhExistingVirus(analysisQueryVo);
            //抗震设防类别
            jsonObject.put("yhEarthFortification",mapList);
            //原抗震设防烈度
            jsonObject.put("yhEarthIntensity",yhEarthIntensity);
            //现抗震设防烈度
            jsonObject.put("countYhNowEarthQh",countYhNowEarthQh);
            //场地类型
            jsonObject.put("countYhFieldType",countYhFieldType);
            //地段类型
            jsonObject.put("countYhLotType",countYhLotType);
            //现存病害
            jsonObject.put("yhExistingVirus",yhExistingVirus);
            responseRest=RestResponse.succeed(jsonObject);
        }catch (Exception e) {
            String errorMessage = "查询失败!";
            responseRest = RestResponse.fail(errorMessage);
        }
        return responseRest;
    }

}
